/**
 * output package name
 */
package com.kingdee.eas.custom.cifisms.smsReport;

import java.awt.event.ActionEvent;

import org.apache.log4j.Logger;

import com.kingdee.bos.BOSException;
import com.kingdee.bos.ctrl.kdf.table.KDTable;
import com.kingdee.bos.ctrl.kdf.table.event.KDTDataRequestEvent;
import com.kingdee.bos.ui.face.CoreUIObject;
import com.kingdee.eas.framework.report.ICommRptBase;
import com.kingdee.eas.framework.report.client.CommRptBaseConditionUI;
import com.kingdee.eas.framework.report.util.RptParams;
import com.kingdee.eas.framework.report.util.RptRowSet;
import com.kingdee.eas.framework.report.util.RptTableHeader;
import com.kingdee.eas.framework.report.util.KDTableUtil;

/**
 * output class name
 */
public class SmsPersonReportUI extends AbstractSmsPersonReportUI {
    private static final Logger logger = CoreUIObject.getLogger(SmsPersonReportUI.class);
    
    /**
     * output class constructor
     */
    public SmsPersonReportUI() throws Exception
    {
        super();
        kDTable1.checkParsed();
        kDTable1.getDataRequestManager().addDataRequestListener(this);
        kDTable1.getDataRequestManager().setDataRequestMode(1);
        enableExportExcel(kDTable1);
    }
    
    public void onLoad() throws Exception {
    	super.onLoad();
    }
    
    public void onShow() throws Exception {
    	super.onShow();
    }
    
    protected RptParams getParamsForInit() {
		RptParams initParam = new RptParams();
		return initParam;
	}

	protected CommRptBaseConditionUI getQueryDialogUserPanel() throws Exception {
		return new SmsPersonReportFilterUI();
	}

	protected ICommRptBase getRemoteInstance() throws BOSException {
		return SmsPersonReportFacadeFactory.getRemoteInstance();
	}

	protected KDTable getTableForPrintSetting() {
		return kDTable1;
	}

	protected void query() {
		kDTable1.removeColumns();
		kDTable1.removeRows();
	}

    
    /**
     * output storeFields method
     */
    public void storeFields()
    {
        super.storeFields();
    }

	public void tableDataRequest(KDTDataRequestEvent e) {
		try{
            int from = e.getFirstRow();
            int len = (e.getLastRow() - from) + 1;
            RptParams pp = new RptParams();
            RptParams rpt;
            if(from == 0){
                pp.setObject("params", params);
                rpt = SmsPersonReportFacadeFactory.getRemoteInstance().createTempTable(pp);
                setTempTable(rpt.getString("tempTable"));
                RptTableHeader header = (RptTableHeader)rpt.getObject("header");
                KDTableUtil.setHeader(header, kDTable1);
                kDTable1.setRowCount(rpt.getInt("verticalCount"));
//            }
            pp.setString("tempTable", getTempTable());
            rpt = SmsPersonReportFacadeFactory.getRemoteInstance().query(pp, from, len);
            RptRowSet rs = (RptRowSet)rpt.getObject("rowset");
            KDTableUtil.insertRows(rs, from, kDTable1);
            }
		}catch(Exception ex)
        {
            handleException(ex);
        }
	}

	
	protected boolean initDefaultFilter(){
    	return false;
    }

}